/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simhya.matheval;

import java.util.Locale;

/**
 *
 * @author Luca
 */
public class NumericNode extends ExpressionNode {
    private Integer intValue;
    private boolean scientificNotation;


    public NumericNode(double value, boolean scientificNotation) {
        super(0);
        super.value = value;
        this.scientificNotation = scientificNotation;
        this.intValue = null;
    }

    public NumericNode(int value) {
        super(0);
        super.value = value;
        this.scientificNotation = false;
        this.intValue = value;
    }


    @Override
    String getExpressionString(boolean fullNumberRepresentation) {
        String s = "", args, argn;
        if (fullNumberRepresentation) {
            args = "%e"; argn = "%f";
        } else { args = "%.4e"; argn = "%.6f"; }
        if (this.intValue != null)
            s += intValue.toString();
        else if (this.scientificNotation)
            s += String.format(Locale.US, args, value);
        else
            s += String.format(Locale.US, argn, value);
        return s;
    }

    @Override
    void computeValue() {
       
    }

    @Override
    void computeValue(SymbolArray varReference) {
        
    }

    @Override
    void computeValue(int evaluationCode) {
        
    }

    @Override
    void computeValue(SymbolArray varReference, int evaluationCode) {

    }

}
